# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
pkgname=pmdk
pkgver=1.12.0
pkgrel=0
pkgdesc="Persistent Memory Development Kit"
url="https://pmem.io/"
# others not supported
arch="aarch64 ppc64le riscv64 x86_64"
license="BSD-3-Clause"
# needs patching for -Wall and __off_t
options="!check"
makedepends="bash cmake fts-dev libexecinfo-dev libunwind-dev linux-headers ndctl-dev perl"
subpackages="$pkgname-dev $pkgname-debug $pkgname-bash-completion:bash_completion"
source="$pkgname-$pkgver.tar.gz::https://github.com/pmem/pmdk/archive/$pkgver.tar.gz
	10-include.patch
	20-doc.patch
	30-etc.patch
	"

prepare() {
	default_prepare
	touch .skip-doc
}

build() {
	export CFLAGS="$CFLAGS"
	export LIBS="$LIBS -ldaxctl -lexecinfo -lfts -lndctl -lunwind"
	export LDFLAGS="$LDFLAGS $LIBS"
	NORPATH=1 BUILD_EXAMPLES=n make
}

package() {
	make install prefix=/usr DESTDIR="$pkgdir"
}

debug() {
	amove usr/lib/pmdk_debug/*.so.*
}

dev() {
	default_dev
	amove usr/lib/pmdk_debug/*.so
}

bash_completion() {
	pkgdesc="Bash completions for pmdk"
	depends=

	install_if="pmdk=$pkgver-r$pkgrel bash-completion"
	amove etc/bash_completion.d/*
}

sha512sums="
f89dc7d9f93854fef287ba4298faf82c27c9f359d9b90bc20bb60919ea2ad50b70c5b62892c511ef3f5059cee77f2edd8a3a818895d2426c4ce7533f867f1e23  pmdk-1.12.0.tar.gz
36b0ac1aa2ed266a5350502bd402e334775f565976f2af881e9bcf830d27e3aeb5be49a7c2b32530bbbd526aa358bc6523064566abdba915240044b989f895b8  10-include.patch
dac444c41a1720a1d5ffae88fdf57277eac65bf0fe774a950cb32330975ed7b6dc765764acd9f54ed101a9871f1db39672c855dbc2ee71bf83053455d9a90ee4  20-doc.patch
b017b8dfbf0a99f329d755daa2b50960c5b1281f9d13e3b77a71bcc2c330d2561097f6d3782e5ad3bc7a456069bb9a86599b771e2b442121a120c53ee6f679bd  30-etc.patch
"
